package com.byyy.ccts.modules.sys.service.impl;

import com.byyy.ccts.core.common.service.impl.CommonServiceImpl;
import com.byyy.ccts.modules.sys.entity.Dict;
import com.byyy.ccts.modules.sys.mapper.DictMapper;
import com.byyy.ccts.modules.sys.service.IDictService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional
@Service("dictService")
public class DictServiceImpl extends CommonServiceImpl<DictMapper, Dict> implements IDictService {

	@Override
	public List<Dict> selectDictList() {
		return baseMapper.selectDictList();
	}

	@Override
	public List<Dict> selectDictListByGCode(String gCode, String dValue) {
		return baseMapper.selectDictListByGCode(gCode, dValue);
	}

	/**
	 * 更新数据字典状态
	 * @param ids
	 * @param state
	 */
	@Override
	public void updateState(List<String> ids, String state) {
		this.baseMapper.updateState(ids, state);
	}

	@Override
	public List<Dict> selectDictUsedListByGCode(String gCode, String dValue) {
		return this.baseMapper.selectDictUsedListByGCode(gCode, dValue);
	}

	/**
	 * 根据用户获取对应的角色数据权限
	 * @param userId
	 * @return
	 */
	@Override
	public List<Dict> selectRoleDataPermissionByUser(String userId, String code) {
		return this.baseMapper.selectRoleDataPermissionByUser(userId, code);
	}

	/**
	 * 根据用户获取对应的用户数据权限
	 * @param userId
	 * @return
	 */
	@Override
	public List<Dict> selectUserDataPermissionByUser(String userId, String code) {
		return this.baseMapper.selectUserDataPermissionByUser(userId, code);
	}

	/**
	 * 构造数据权限树结构
	 * @return
	 */
	@Override
	public List<Dict> selectDataPermissionTreeList() {
		return this.baseMapper.selectDataPermissionTreeList();
	}

	/**
	 * 根据角色ID获取角色赋予的数据权限
	 * @return
	 */
	@Override
	public List<Dict> findDataPermissionByRoleId(String roleId) {
		return this.baseMapper.findDataPermissionByRoleId(roleId);
	}

	/**
	 * 根据角色ID获取角色赋予的数据权限
	 * @return
	 */
	@Override
	public List<Dict> findDataPermissionByUserId(String roleId) {
		return this.baseMapper.findDataPermissionByUserId(roleId);
	}

}
